<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <%@include file="../_static/_head.jsp"%>
</head>
<body>
<article class="page-container">
    <form class="form form-horizontal" id="form">
        <div class="row cl">
            <input type="hidden" id="id" name="id" value="${backMenu.id}">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>页面编码：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" id="code" name="code" value="${backMenu.code}">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>页面名称：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" autocomplete="off" id="name" name="name" value="${backMenu.name}">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>页面路径：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" autocomplete="off" id="path" name="path" value="${backMenu.path}">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>页面排序：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="number" class="input-text" autocomplete="off" id="sort" name="sort" value="${backMenu.sort}">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">状态：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <span class="select-box" style="width:150px;">
                    <select class="select" name="state" id="state" size="1">
                        <option value="0" <c:if test="${backMenu.state==0}">selected</c:if>>禁用</option>
                        <option value="1" <c:if test="${backMenu.state==1}">selected</c:if>>启用</option>
                    </select>
			    </span>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red"></span>备注：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" id="remark" name="remark" value="${backMenu.remark}">
            </div>
        </div>
        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <input class="btn btn-primary radius" type="submit" value="提交">
            </div>
        </div>
    </form>
</article>
<%@include file="../_static/_foot.jsp"%>
<script>
    $("#form").validate({
        rules:{
            code:{
                required:true
            },
            name:{
                required:true,
            },
            path:{
                required:true
            },
            sort:{
                required:true,
            }
        },
        onkeyup:false,
        focusCleanup:true,
        success:"valid",
        submitHandler:function(form){
            $(form).ajaxSubmit({
                type: 'POST',
                url: "/sys/menu/saveupdate.json" ,
                success: function(data){
                    if (data.code==200){
                        window.parent.location.reload();
                        layer.msg('添加成功!',{icon:1,time:1000});
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                    } else{
                        layer.msg(data.msg,{icon:2,time:1000});
                    }
                },
                error: function(XmlHttpRequest, textStatus, errorThrown){
                    layer.msg('错误!',{icon:2,time:1000});
                }
            });

        }
    });
</script>
</body>
</html>
